package com.kaili.basic.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.entity.BaseParameterControl;
import com.kaili.basic.mapper.BaseParameterControlMapper;
import com.kaili.basic.pojo.vo.BaseParameterControlVO;
import com.kaili.basic.service.IBaseParameterControlService;
import com.kaili.common.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  参数控制服务实现类
 * </p>
 *
 * @author nigang
 * @since 2018-06-28
 */
@Service
@Transactional
public class BaseParameterControlServiceImpl implements IBaseParameterControlService {

    @Autowired
    BaseParameterControlMapper baseParameterControlMapper;

    @Override
    public Page<BaseParameterControlVO> getAllParameterControl(Page<BaseParameterControl> page, BaseParameterControl parameterControl) {
        Page<BaseParameterControlVO> pageVO=new Page<BaseParameterControlVO>(page.getCurrent(),page.getSize());
        List<BaseParameterControl> list = baseParameterControlMapper.getAllParameterControl(page, parameterControl);
        List<BaseParameterControlVO> voList = CommonUtil.toList(list, BaseParameterControlVO.class);
        return pageVO.setRecords(voList);
    }

    @Override
    public BaseParameterControl getParameterControlById(Integer parameterId) {
        return baseParameterControlMapper.getParameterControlById(parameterId);
    }

    @Override
    public BaseParameterControl getParameterByCompany() {
        return baseParameterControlMapper.getParameterByCompany();
    }

    @Override
    public BaseParameterControl getParameterControlBySiteUser(BaseParameterControl parameterControl) {
        return baseParameterControlMapper.getParameterControlBySiteUser(parameterControl);
    }

    @Override
    public int updateParameterControl(BaseParameterControl parameterControl) {
        return baseParameterControlMapper.updateParameterControl(parameterControl);
    }

    @Override
    public int addParameterControl(BaseParameterControl parameterControl) {
        return baseParameterControlMapper.addParameterControl(parameterControl);
    }

    @Override
    public int deleteParameterControlById(Integer parameterId) {
        return baseParameterControlMapper.deleteParameterControlById(parameterId);
    }
}
